/**
 * 
 */
package orion.jarvis.task.event;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import orion.jarvis.task.Condition;
import orion.jarvis.task.Message;
import orion.jarvis.task.Task;


/**
 * @author Ted
 * 
 */
public class LogTaskEventListener {

	private static Logger log = LoggerFactory.getLogger(LogTaskEventListener.class);

	public boolean interested(TaskEventCategory category) {
		if (category instanceof TaskEventCategory)
			return true;
		else
			return false;
	}

	public void perform(TaskEvent event) {
		TaskEventCategory category = event.getCategory();
		if (category != null) {
			log.debug("Event: {0}", category.getDesc());
		}
		EventData data = event.getEventData();
		if (data != null) {
			Integer id = data.getTaskId();
			if (id != null)
				log.debug("Task Id:", id.toString());
			Task task = data.getTask();
			if (task != null)
				log.debug("Task:", task.toString());
			if (data instanceof EventData) {
				List<Task> taskList = ((EventData) data).getTaskList();
				if (taskList != null)
					log.debug("Task list size:", taskList.size());
				Condition cond = ((EventData) data).getCondition();
				if (cond != null)
					log.debug("Condition:", cond.getDesc());
				Message msg = ((EventData) data).getMessage();
				if (msg != null)
					log.debug("Message:", msg.toString());
			}
		}
	}

}
